<template>
  <div class="all">
    <el-card class="box-card">
      <span slot="header" class="title">用户注册</span>
      <el-form label-width="80px" style="width: 300px; margin: 20px auto">
        <el-form-item label="账户类型">
        <el-radio v-model="role_id" label="1">租户</el-radio>
        <el-radio v-model="role_id" label="2">出租户</el-radio>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" style="width: 100px" @click="onSubmit">立即注册</el-button>
        <el-button style="width: 100px" @click="cancle">取 消</el-button>
      </el-form-item>
      </el-form>
    </el-card>
  </div>
</template> 
<script>
export default {
  data() {
    return {
      role_id: "1",
      roleList:{},
      user_telephone:'',
      user_id:''
    };
  },
  methods:{
      onSubmit(){
          this.$axios.get("/addUserRole",{
              params:{
                  user_id:this.user_id,
                  role_id:this.role_id
              }
          }).
          then(res=>{
              alert(res.data.messages);
              this.$router.push("/");
          }).catch(error=>{

          })
      },

      getUserId(){
          this.$axios.get("/getUserId/"+this.user_telephone).
          then(res=>{
              this.user_id=res.data.data.user_id;
          }).catch(error=>{ 

          })
      },
      cancle(){
        this.$axios.get("/deleteUserinfo/"+this.user_id).
        then(res=>{
          this.$router.push("/Reset"); 
        }).catch(error=>{

        })
      }
  },

  mounted(){
      this.user_telephone = sessionStorage.getItem("reset_telephone");
      this.getUserId();
  }
};
</script>

<style>
.loginFrom {
  border: 1px solid white;
  background-color: aliceblue;
  width: 550px;
  height: 400px;
  margin-top: 10%;
  margin-left: 32%;
}
.all {
  border: 1px solid white;
  height: 700px;
  background-image: url("../../assets/beijing.jpg");
  background-size: 100% 100%;
}
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}
.title {
  text-align: center;
  font-size: 24px;
  color: rgba(50, 50, 50, 0.8);
}
.box-card {
  background-color: aliceblue;
  border-radius: 10px;
  width: 480px;
  margin: 10% auto;
}
</style>